---
layout: example
categories: example/v1.0.0
version: v1.0.0
title: Draw lines between markers
description: Add a polyline that draws its coordinates from a featureLayer.
tags:
  - vector
---
<div id='map'></div>

<script>
var map = L.mapbox.map('map')
  .setView([37.77396, -122.4366], 12)
  .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));

var myFeatureLayer = L.mapbox.featureLayer('/mapbox.js/assets/data/sf_locations.geojson')
    .addTo(map);

myFeatureLayer.on('ready', function(e) {
  var line = [];

  this.eachLayer(function(marker) {
    line.push(marker.getLatLng());
  });

  var polyline_options = {
    color: '#000'
  };

  var polyline = L.polyline(line, polyline_options).addTo(map);
});
</script>
